package model{
	import flash.display.DisplayObject;
	import flash.display.Sprite;
	import flash.events.*;
	import flash.text.*;
	
	import model.GlobalTextFormat;
	
	public class TitleBar extends Sprite
	{
		[Bindable]
		[Embed('assets/component.swf', symbol='TitleBarMovieClip')]
		private static var TitleBarMovieClip:Class;
		
		private var titleBar:DisplayObject;
		private var label:TextField;
		
		public function TitleBar()
		{
			titleBar = new TitleBarMovieClip();
			label = new TextField();
			addChild(titleBar);
		}
		
		public function set text(value:String):void
		{
			if(!contains(label))
			{				
				label.selectable = false;
				label.multiline = true; 
				label.autoSize = TextFieldAutoSize.CENTER;
				addChild(label);
			}
			
			//label.border = true;
			label.text = value;			
			label.y = 9;
			label.width = titleBar.width;
			label.height = titleBar.height;
			label.setTextFormat(GlobalTextFormat.titleAssetStyle);
		}
		
		override public function set width(value:Number):void
		{
			titleBar.width = value;
		}
		
		override public function get width():Number
		{
			return titleBar.width;
		}
		
		override public function set height(value:Number):void
		{
			titleBar.height = value;
		}
		
		override public function get height():Number
		{
			return titleBar.height;
		}		
	}
}